var app = getApp();
var check = require('../../utils/check.js');
var urlList = require('../../utils/base.js');
var WxParse = require('../../wxParse/wxParse.js');
Page({
	data: {
    baseUrl: urlList.baseUrl,
		info:{},
    article:'',
        maskShow:true
	},
    bindload:function(){
        wx.hideLoading()
        this.setData({
            maskShow: false
        })
    },
	onLoad: function (e) {
        var _this = this;
  
		if (e.id) {
            wx.showLoading({ title: '加载中', mask: true })
            wx.request({
              url: urlList.newsUrl+'/' + e.id,
              header: { 'content-type': 'application/x-www-form-urlencoded', 'token': 'bearer ' },
                method: 'get',
                success: function (res) {
                    console.log(res)
                  
                    if (res.data.status == 0) {
                     
                      WxParse.wxParse('article', 'html', res.data.data.content, _this, 5)
                        _this.setData({
                            info: res.data.data,
                        })
                     
                        wx.setNavigationBarTitle({
                            title: res.data.data.title
                        })
                      _this.bindload();
                    }else{
                      wx.showToast({
                        title: res.data.message,
                        mask: 'false',
                        duration: 2000
                      })
                   
                     
                      // wx.navigateBack({ changed: true });//返回上一页 
                    }
                  
                }
            })
            
		}
	},
  escape2Html : function (str) {
    var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' };
    return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; });
  }
})
